package com.example.oauth2demo.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * TODO
 *
 * @author karidyang
 * @since 1.0
 * Date: 2021-04-27
 **/
@Configuration
@Order(Ordered.HIGHEST_PRECEDENCE)
public class HttSecurityConfig extends WebSecurityConfigurerAdapter {
    @Autowired(required = false)
    private CustomWebSecurityConfigurer customWebSecurityConfigurer;

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().antMatchers("/", "/login_back").permitAll();

        System.out.println("HttSecurityConfig [" + http + "]");
        if (customWebSecurityConfigurer != null) {
            customWebSecurityConfigurer.configure(http);
        }
        http.authorizeRequests().anyRequest().denyAll();
    }

}
